package com.icloud.common.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.icloud.common.exception.ClientInputException;


public class JakcsonUtils {
    public static String toJson(Object obj){
        ObjectMapper mapper = new ObjectMapper();

        String mapJakcson ;
        try {
            mapJakcson =  mapper.writeValueAsString(obj);
        } catch (JsonProcessingException e) {
            throw new ClientInputException(obj.getClass().getName()+":转json失败");
        }
        return mapJakcson;
    }
}
